import $ from '../../utils/ajax.js';
import util from '../../utils/util.js';
const app = getApp();
Page({
    data: {
        content: [],
        putData:{
            page: 1,
            size: 10,
            status: 0,
        }
    },
    onLoad(options) {
        this.getWithDrawRecord(this.data.putData);
    },
    goStatus({ target: { dataset: { id } } }) {
        this.setData({
            'putData.status': Number(id),
            'putData.page': 1
        }, () => {
            this.getWithDrawRecord(this.data.putData)
        })
    },
    getWithDrawRecord(data) {
        $.p(app.wxApp.url + 'agentnew/withdrawalList', {...data}, app.onStrart, (res) => {
            let prime = [];
            if (res.data.page === 1) {
                prime = res.data.list;
            } else {
                prime = this.data.content.concat(res.data.list);
            }
            this.setData({
                content: prime
            })
            app.onShop();
        }, (res) => {
            util.showToast(res.data)
        })
    },
    omn(res) {
        wx.navigateTo({
            url: './details/details?item=' + JSON.stringify(res.currentTarget.dataset.id)
        })
    },
    onReachBottom(e) {
        this.setData({
            ['putData.page']: this.data.putData.page + 1
        }, () => {
            this.getWithDrawRecord(this.data.putData);
        })
    }
})